import groovy.text.GStringTemplateEngine

def text = '''
<%
def ObjectUtils = com.springsource.util.common.CollectionUtils;
%>
Dear "$firstname $lastname",
  So nice to meet you in <% out<< city %>.
  <%
  out << System.currentTimeMillis()
  sb.append("abc").append("-").append('bcd');
  out << sb
  if(ObjectUtils.isEmpty([])) {
      out << "\\nEMPTY"
  } else {
      out << "\\nNOT EMPTY"
  }
  %>
  See you in ${month},
  ${signed}'''

def binding = ["firstname":"Sam", "lastname":"Pullara", "city":"San Francisco", "month":"December", "signed":"Groovy-Dev", "sb":new StringBuilder()]

def engine = new GStringTemplateEngine()
template = engine.createTemplate(text).make(binding)

// def result = 'Dear "Sam Pullara",\nSo nice to meet you in San Francisco.\nSee you in December,\nGroovy-Dev'

//assert result == template.toString()

template.toString()

